if (!jsx3.lang.Class.forName("ux.cdb.admin.CommonCache")) {
	jsx3.lang.Class.defineClass("ux.cdb.admin.CommonCache", null, null, 
		function(cache) {

			cache.commonCache = {};

            cache.serverCache = ux.megatron.Main.getServer().getCache();

			cache._instance = null;
			
			cache.getInstance = function(){
				if(!this._instance)
					this._instance = new cache(); 
				return this._instance;
			};
			
			cache.prototype.cacheIdCount = 0;
			cache.prototype.cacheIdStep = 0;
			cache.prototype.callbackScope = this;
			cache.prototype.callbackFunction = function(){};
			
			/**
			* Load common data from cache. you can update this class by your self.
			* e.g. if you want load category1 and category2 to your page,use this:
			* 	ux.cdb.admin.CommonCache.loadCache(['Category1','Category2'],this,function(){
			*		//this is your call back function.
			*   });
			* and your cacheid is 'CommonCache_**'
			* @params cacheIds(Array) the cache id which you want to load.
			*/
            cache.loadCache = function(cacheIds, scope, callback) {
				if(!cacheIds || !(cacheIds instanceof Array)) return;
				try{
					var _cache = cache.getInstance();
					_cache.cacheIdCount = cacheIds.length;
					if(scope) 
						_cache.callbackScope = scope;
					if(callback && typeof(callback) == 'function') 
						_cache.callbackFunction = callback;
					ux.megatron.util.Dwr.beginBatch();
					for(var i=0;i<_cache.cacheIdCount;i++){
						var cacheObjName = cacheIds[i].toString().toLowerCase();
						var childObj = eval('cache.commonCache.' + cacheObjName);
						jsx3.log('CommonCache#loadCache cacheObj : ' + childObj + ' : ' + cacheObjName + ' : ' + cacheIds[i]);
						if(childObj && childObj.cdf && childObj.cdf.toString() != '<data jsxid="jsxroot"/>') {
							jsx3.log('CommonCache#loadCache cacheObj.cdf : ' + childObj.cdf.toString() + ' :[' + (childObj.cdf.toString() != '<data jsxid="jsxroot"/>') + ']');
							_cache._setCallback();
						}else{
							jsx3.log('CommonCache#loadCache load cacheObj.cdf ...');
							eval('cache.commonCache.' + cacheObjName + ' = {name:"CommonCache_' + cacheIds[i] + '",cdf:null};');
							jsx3.log('CommonCache#loadCache _loadCommonData("' + cacheIds[i] + '", "' + cacheObjName + '");');
							cache.getInstance()._loadCommonData(cacheIds[i], cacheObjName);
						}
					}
					ux.megatron.util.Dwr.endBatch();
				}catch(e){
					jsx3.log('CommonCache#loadCache Error : ' + e.message);
					throw e;
				}
            };

			cache.prototype._setCallback = function() {
				this.cacheIdStep++;
				jsx3.log('cacheIdStep : ' + this.cacheIdStep + ' | cacheIdCount : ' + this.cacheIdCount);
				if(this.cacheIdStep === this.cacheIdCount){
					this.cacheIdStep = 0;
					this.callbackFunction.call(this.callbackScope);
				}
			};
			
			cache.prototype._convertToCDF = function(data, cacheObjName) {
				if(!data || !cacheObjName) 
					throw new jsx3.lang.IllegalArgumentException('parameters required!', 'data : ' + data + ',cacheObjName : ' + cacheObjName);
				eval('cache.commonCache.' + cacheObjName + '.cdf = jsx3.xml.CDF.Document.newDocument();');
				for(var i = 0, item; item = data[i]; i++){
					//alert('_convertToCDF#'+cacheObjName+':'+data[i])
					eval('cache.commonCache.' + cacheObjName + '.cdf.insertRecord(item,null,false);');
				}
				eval('cache.serverCache.clearById(cache.commonCache.' + cacheObjName + '.name);');
				eval('cache.serverCache.setDocument(cache.commonCache.' + cacheObjName + '.name, cache.commonCache.' + cacheObjName + '.cdf);');
				jsx3.log('CommonCache#_convertToCDF CDF['+cacheObjName+'] : ' + eval('cache.commonCache.' + cacheObjName + '.cdf'));
				this._setCallback();
			};
			
			/**
			* get object of common cache.
			* @params cacheId(String) the cache id of the object which you want.
			*/
			cache.prototype.getCache = function(cacheId) {
				if(!cacheId || cacheId.indexOf('CommonCache_') != 0)
					throw new jsx3.lang.IllegalArgumentException('parameters must be a string and start with "CommonCache_"!', 'cacheId : "' + cacheId + '"');
				var objCDF = null;
				eval('objCDF = cache.commonCache.' + cacheId.replace('CommonCache_','').toLowerCase() + '.cdf;');
				objCDF = objCDF ? objCDF : jsx3.xml.CDF.Document.newDocument();
				jsx3.log('CommonCache#getCache[' + cacheId + '] : ' + objCDF);
				return objCDF.cloneDocument();
			};

			cache.mock = false;
			cache.prototype._loadCommonData = function(dataType, cacheObjName) {
				if(ux.megatron.Main.isFileSystem()) return;
				if(cache.mock === true){
					eval('cache.getInstance()._load' + dataType + '("' + cacheObjName + '");');
					return;
				}
				var dwrClass = 'BaseUCC';
				var dwrFunction = 'getCodeListByCodeType';
				if(dataType == 'INTERNAL_ORG'){
					dwrClass = 'UserMgrUCC';
					dwrFunction = 'getOrgList';
					dataType = null;
				}
				ux.megatron.util.Dwr.callDwr(dwrClass, dwrFunction, [dataType], this,
					function(data){
						if (data != null && typeof data == 'object') {
							if(window.dwr && dwr.util) { jsx3.log(dwr.util.toDescriptiveString(data, 5)); }
							var _data = data.content.data, recordList = [];
							for(var i = 0, item; item = _data[i]; i++){
								var tmpRecord = {jsxid:item.codeValue, jsxtext:item.codeName};
								recordList.push(tmpRecord);
							}
							if(window.dwr && dwr.util) { jsx3.log(dwr.util.toDescriptiveString(recordList, 5)); }
							this._convertToCDF(recordList, cacheObjName);
						} else {
                            if(window.dwr && dwr.util) { dwr.util.setValue('d0', dwr.util.toDescriptiveString(data, 1)); }
                        }
							
					});
			};


			//////////////////////////////////////////////////////////////
			//////////		TODO: add your mock function under.	/////////
			//////////////////////////////////////////////////////////////
			cache.prototype._loadSCHOOL_PROPERTY = function(objName) {
				var _RecordsOfProperty = [
					{jsxid:'01',jsxtext:'公办'},
					{jsxid:'02',jsxtext:'民办'},
					{jsxid:'03',jsxtext:'独立'},
					{jsxid:'98',jsxtext:'其他'},
					{jsxid:'99',jsxtext:'未知'}
				]; //this will be got from dwr.
				this._convertToCDF(_RecordsOfProperty, objName);
			};

			cache.prototype._loadSCHOOL_CATEG1 = function(objName) {
				var _RecordsOfCategory1 = [
					{jsxid:'01',jsxtext:'普通高校'},
					{jsxid:'02',jsxtext:'高等职业学校'},
					{jsxid:'98',jsxtext:'其他'},
					{jsxid:'99',jsxtext:'未知'}
				];
				this._convertToCDF(_RecordsOfCategory1, objName);
			};

			cache.prototype._loadSCHOOL_CATEG2 = function(objName) {
				var _RecordsOfCategory2 = [
					{jsxid:'01',jsxtext:'中央院校-985院校'},
					{jsxid:'02',jsxtext:'中央院校-211院校'},
					{jsxid:'03',jsxtext:'中央院校-其它部属院校'},
					{jsxid:'04',jsxtext:'地方院校-外地院校'},
					{jsxid:'05',jsxtext:'地方院校-本省院校'},
					{jsxid:'06',jsxtext:'省属院校'},
					{jsxid:'07',jsxtext:'地市级院校'},
					{jsxid:'98',jsxtext:'其他'},
					{jsxid:'99',jsxtext:'未知'}
				];
				this._convertToCDF(_RecordsOfCategory2, objName);
			};
			
			cache.prototype._loadPROVINCE = function(objName) {
				var _Records = [
					{jsxid:'01',jsxtext:'北京市'},
					{jsxid:'02',jsxtext:'上海市'}
				];
				this._convertToCDF(_Records, objName);
			};

			cache.prototype._loadQualification = function(objName) {
				var _RecordsOfQualification = [
					{jsxid:'01',jsxtext:'小学'},
					{jsxid:'02',jsxtext:'中学'},
					{jsxid:'03',jsxtext:'中专'},
					{jsxid:'04',jsxtext:'专科'},
					{jsxid:'05',jsxtext:'本科'},
					{jsxid:'06',jsxtext:'硕士'},
					{jsxid:'07',jsxtext:'博士'},
					{jsxid:'08',jsxtext:'博士后'},
					{jsxid:'98',jsxtext:'其他'},
					{jsxid:'99',jsxtext:'未知'}
				];
				this._convertToCDF(_RecordsOfQualification, objName);
			};

			//分行（内部机构）
			cache.prototype._loadInternalOrgan = function(objName) {
				var _Records = [
					{jsxid:'1100',jsxtext:'总行营业部'},
					{jsxid:'1200',jsxtext:'天津分行'},
					{jsxid:'1310',jsxtext:'河北分行'},
					{jsxid:'1410',jsxtext:'山西分行'},
					{jsxid:'1510',jsxtext:'内蒙古分行'},
					{jsxid:'2110',jsxtext:'辽宁分行'},
					{jsxid:'2120',jsxtext:'大连分行'},
					{jsxid:'2210',jsxtext:'吉林分行'},
					{jsxid:'2310',jsxtext:'黑龙江分行'},
					{jsxid:'3100',jsxtext:'上海分行'},
					{jsxid:'3210',jsxtext:'江苏分行'},
					{jsxid:'3310',jsxtext:'浙江分行'},
					{jsxid:'3302',jsxtext:'宁波分行'},
					{jsxid:'3410',jsxtext:'安徽分行'},
					{jsxid:'3510',jsxtext:'福建分行'},
					{jsxid:'3502',jsxtext:'厦门代表处'},
					{jsxid:'3610',jsxtext:'江西分行'},
					{jsxid:'3710',jsxtext:'山东分行'},
					{jsxid:'3702',jsxtext:'青岛分行 '},
					{jsxid:'4110',jsxtext:'河南分行'}
				];
				this._convertToCDF(_Records, objName);
			};

			//合作协议类别
			cache.prototype._loadCooperAgreementType = function(objName) {
				var _Records = [
					{jsxid:'001',jsxtext:'担保类'},
					{jsxid:'002',jsxtext:'投融资类'},
					{jsxid:'003',jsxtext:'小额信贷类'},
					{jsxid:'004',jsxtext:'生源地助学贷款类'},
					{jsxid:'98',jsxtext:'其他'},
					{jsxid:'99',jsxtext:'未知'}
				];
				this._convertToCDF(_Records, objName);
			};

			//与学生借款关系
			cache.prototype._loadRelationOfStudent = function(objName) {
				var _Records = [
					{jsxid:'01',jsxtext:'父子'},
					{jsxid:'02',jsxtext:'母子'},
					{jsxid:'98',jsxtext:'其他'},
					{jsxid:'99',jsxtext:'未知'}
				];
				this._convertToCDF(_Records, objName);
			};
		}
	);
}